package com.example.dbsample.web;

import com.alibaba.fastjson.JSONObject;
import com.example.dbsample.service.business.SysDictDataService;
import com.example.dbsample.model.http.LujsResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mock")
public class MockFeignController extends BaseRest {
    SysDictDataService sysDictDataService;

    //@Value("${mock.tts.float:1.1}")
    //private Float mockTtsFloatValue;
    //
    //private DownStreamFeign downStreamFeign;
    //
    //private DownStreamFeignV2 downStreamFeignV2;

    //public MockFeignController(SysDictDataService sysDictDataService, DownStreamFeign downStreamFeign, DownStreamFeignV2 downStreamFeignV2) {
    //public MockFeignController(DownStreamFeign downStreamFeign, DownStreamFeignV2 downStreamFeignV2) {
    public MockFeignController(SysDictDataService sysDictDataService) {
        this.sysDictDataService = sysDictDataService;
        //this.downStreamFeign = downStreamFeign;
        //this.downStreamFeignV2 = downStreamFeignV2;
    }

    @PostMapping("/feign/callBatchReceive")
    public LujsResponse<Object> callBatchReceive(@RequestBody String request) {

        //RespCallSession session = new RespCallSession();
        //session.setSeqNo(100);

        //sysDictDataService.querySysDictDataEntityByQueryWrapper(0);

        //JSONObject downStreamRequest = new JSONObject();
        //downStreamRequest.put("request", request);
        //
        //// TODO feign调用失败，待排查
        //JSONObject response = this.downStreamFeign.batchReceive(downStreamRequest);
        //
        //System.out.printf("成功请求接口/mock/feign/callBatchReceive, mockTtsFloatValue: " + mockTtsFloatValue);
        //
        return LujsResponse.ofSuccess();
    }

    @PostMapping("/feign/callBatchReceiveV2")
    public LujsResponse<Object> callBatchReceiveV2(@RequestBody String request) {

        //RespCallSession session = new RespCallSession();
        //session.setSeqNo(100);

        sysDictDataService.querySysDictDataEntityByQueryWrapper(0);

        //JSONObject downStreamRequest = new JSONObject();
        //downStreamRequest.put("request", request);
        //
        //
        //// TODO feign调用失败，待排查
        //JSONObject response = this.downStreamFeignV2.batchReceive(downStreamRequest);
        //
        //System.out.printf("成功请求接口/mock/feign/callBatchReceivev2, mockTtsFloatValue: " + mockTtsFloatValue);

        return LujsResponse.ofSuccess();
    }

    @PostMapping("/feign/batchReceive")
    public LujsResponse<Object> batchReceive(@RequestBody JSONObject request) {

        //RespCallSession session = new RespCallSession();
        //session.setSeqNo(100);

        // TODO 这个类已经迁移到db工程
        sysDictDataService.querySysDictDataEntityByQueryWrapper(0);

        //System.out.printf("成功进入接口/mock/feign/batchReceive, mockTtsFloatValue: " + mockTtsFloatValue);
        //
        return LujsResponse.ofSuccess();
    }
}